
import 'package:floor/floor.dart';

@entity
class User {

  @primaryKey
  late String id;
  String? userId;
  String? username;
  String? avatar;
  String? email;

  User(this.id, {this.userId, this.username, this.avatar, this.email});

  String get getId => id;

  String get getUserName => username??"";

  String get getAvatar => avatar??"";

  String get getEmail => email??"";

  User.fromJson(Map<String, dynamic> json) {
    id = "1";
    userId = json['userid'];
    username = json['username'];
    avatar = json['avatar'];
    email = json['email'];
  }

  Map<String, dynamic> toJson() {
    final data = <String, dynamic>{};
    data['id'] = id;
    data['nickname'] = username;
    data['avatar'] = avatar;
    data['email'] = email;
    return data;
  }
}
